package com.example.capsule_kafka.service;


import com.example.capsule_kafka.bean.OneToOneMessageBean;
import com.example.capsule_kafka.mapper.OneToOneMessageMapper;
import com.google.gson.Gson;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: zhuzhiming
 * @Date: 2022/5/4 0:04
 */
@Service
public class OneToOneMessageService {

    @Resource
    OneToOneMessageMapper oneToOneMessageMapper;

    public String getMessages(String roomName) {

        List<OneToOneMessageBean> oneToOneBeanList = oneToOneMessageMapper.getMessagesList(roomName);

        if (oneToOneBeanList == null || oneToOneBeanList.size() == 0) {
            return "";
        }
        return new Gson().toJson(oneToOneBeanList);

    }
}
